import request from '@/utils/request'
import type { AttributeItem,AttributeResponse,CategoryOneResponse , CategoryTwoResponse, CategoryThreeResponse } from '@/types/product/attribute'

// 封装属性页面相关请求接口

// 获取一级分类接口
export const getCategoryOneListAPI = () => {
    return request.get<any, CategoryOneResponse>('/admin/product/getCategory1')
}

// 获取二级分类接口
export const getCategoryTwoListAPI = (category1Id: number) => {
    return request.get<any, CategoryTwoResponse>(`/admin/product/getCategory2/${category1Id}`)
}

// 获取三级分类接口
export const getCategoryThreeListAPI = (category2Id: number) => {
    return request.get<any, CategoryThreeResponse>(`/admin/product/getCategory3/${category2Id}`)
}

// 获取平台属性接口
export const getAttributeListAPI = (category1Id: number, category2Id: number, category3Id: number) => {
    return request.get<any, AttributeResponse>(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)
}

// 添加修改属性接口
export const addOrUpdateAttributeAPI = (data: AttributeItem) => {
    return  request.post<any,any>("/admin/product/saveAttrInfo",data)
}

// 删除属性接口
export const deleteAttributeAPI = (attrId: number | string) => {
    return  request.delete<any,any>(`/admin/product/deleteAttr/${attrId}`)
}

// 获取属性详情接口
export const getAttributeDetailAPI = (attrId: number | string) => {
    return  request.get<any,any>(`/admin/product/getAttrValueList/${attrId}`)
}